package com.killgun.configuration;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * Manages the configuration file. ConfigManager is a static class that is only
 * available via the getInstance() method.
 *
 * @author Tim Terhorst
 */
public class ConfigManager {

    private static final Properties prop = new Properties();
    private static final String FILE = "config.properties";

    //singleton
    private ConfigManager() {
    }

    /**
     * Returns the available Properties configuration.
     * @return Properties prop
     */
    public static Properties getInstance() {
        if (prop.isEmpty()) {
            try {
                prop.load(new FileInputStream(FILE));
            } catch (IOException iox) {
                // if this fails currently the game will crash
                System.err.println("Couldn't load properties file.");
            }
        }

        return prop;
    }
}
